package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.anno.AutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealMapper {
    @AutoFill(OperationType.UPDATE)
    void update(Setmeal setmeal);

    Page<SetmealVO> page(SetmealPageQueryDTO dto);

    @AutoFill(OperationType.INSERT)
    @Insert("insert into setmeal (name, category_id, price, status, " +
            "description, image, create_time, update_time, create_user, update_user) " +
            "values (#{name}, #{categoryId}, #{price}, #{status}, " +
            "#{description}, #{image}, #{createTime}, #{updateTime}, #{createUser}, #{updateUser})")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    void save(Setmeal setmeal);

    void insertSetmealDish(List<SetmealDish> setmealDishes);

    @Select("select * from setmeal where id=#{id}")
    Setmeal getById(Long id);

    Integer getByIds(List<Long> ids);

    void delete(List<Long> ids);
}
